package com.work.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.work.bean.DiseaseBean;
import com.work.bean.PestsBean;
import com.work.mapper.DiseaseMapper;
import com.work.service.IDiseaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
@Service
@Transactional
public class IDiseaseServiceImpl extends ServiceImpl<DiseaseMapper, DiseaseBean> implements IDiseaseService {
    @Resource
    private DiseaseMapper mapper;
    @Override
    public Page<DiseaseBean> findByItem(Integer pageNo, Integer pageSize, String DiseaseName, String diseaseSymptom) {
        Page<DiseaseBean> page = new Page<>(pageNo,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if(DiseaseName!=null && !DiseaseName.equals("")){
            wrapper.like("disease_name", DiseaseName);
        }if(diseaseSymptom!=null && !diseaseSymptom.equals("")){
            wrapper.like("pests_host", diseaseSymptom);
        }
        mapper.selectPage(page, wrapper);

        return page;
    }
}
